<!DOCTYPE html>
<html>
<head>
<title>template</title>
<meta name="keywords" charset=utf-8/>
<!--[if !IE]> -->
  <script src="http://cdn.bootcss.com/jquery/2.2.0/jquery.min.js"></script>
  <!-- <![endif]-->
  <!--[if IE]>
      <script src="http://cdn.bootcss.com/jquery/1.12.0/jquery.js"></script>
  <![endif]-->
<style>
*{
  margin:0;
  padding:0;
}
#mydiv{
  color: blue;
  font-size: -webkit-xxx-large;
}

</style>
</head>
<body>
  <div id="mydiv">hello js</div>

<script>
var a = document.getElementById("mydiv");
var res = getStyle(a,'color');
console.log(res)
function getStyle(obj,attr,value){
  if(!value)
  {
    if(obj.currentStyle){ 
    return obj.currentStyle[attr]; //IE独有方法，作用在DOM元素上，不支持伪类
  }else{ 
    return getComputedStyle(obj,false)[attr]; 
  } 
  }else{
    obj.style[attr] = value;
  }
}
</script>
</body>
</html>